﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Service;
using Model;
using System.Data;
using System.Reflection;
namespace Manager
{
    public class ReportManager
    {
        Report_TB_GradeService service = new Report_TB_GradeService();
        public DataSet GetReport(string rid, string tjnd, string schooltype,string districtid)
        {
            //schooltype = schooltype + "%";
            //if (rid == "01")
            //{
            //    return service.GetReport(rid, tjnd, schooltype, districtid);
            //}
            //else if (rid == "02")
            //{
            //    return service.GetReport2(rid, tjnd, schooltype, districtid);
            //}
            //else if (rid == "03")
            //{
            //    return service.GetReport3(rid, tjnd, schooltype, districtid);
            //}
            //else if (rid == "04")
            //{
            //    return service.GetReport4(rid, tjnd, schooltype, districtid);
            //}
            return null;
        }
        /// <summary>
        /// 身高体重报表
        /// </summary>
        /// <param name="rid"></param>
        /// <param name="tjnd"></param>
        /// <param name="schooltype"></param>
        /// <param name="districtid"></param>
        /// <returns></returns>
        public DataSet GetXXReport(string rid, string tjnd, string schooltype, string districtid,ReportType rt)
        {
            schooltype = schooltype + "%";
            switch(rt)
            {
                case ReportType.Sg:
                    return service.GetReportSg(tjnd, schooltype, districtid);
                case ReportType.Tz:
                     return service.GetReportTz(tjnd, schooltype, districtid);
                case ReportType.Xw:
                    return service.GetReportXw(tjnd, schooltype, districtid);
                case ReportType.Hfl:
                    return service.GetReportFhl(tjnd, schooltype, districtid);
                default: return new DataSet();
            }
        }
    }
    public class ReportFactory
    {
        public static IReport CreateReport(string name)
        {
            string objectString= System.Configuration.ConfigurationManager.AppSettings[name].ToString();
            Type objecType = Type.GetType(objectString);
            IReport Report =(IReport)Activator.CreateInstance(objecType);
            return Report;
        }
    }
    public class ReportManger1 : IReport
    {
        Report_TB_GradeService service = new Report_TB_GradeService();
        AgeReportService ageService = new AgeReportService();
        public DataSet GetReport(string tjnd, string schooltype, string districtid, string ctype)
        {
            if (ctype == "Age")
            {
                return ageService.GetReport(tjnd, schooltype, districtid);
            }
            else
            {
                return service.GetReport(tjnd, schooltype, districtid);
            }
        }
    }
    public class ReportManger2 : IReport
    {
        Report_TB_GradeService service = new Report_TB_GradeService();
        AgeReportService ageService = new AgeReportService();
        public DataSet GetReport(string tjnd, string schooltype, string districtid, string ctype)
        {
            if (ctype == "Age")
            {
                return ageService.GetReport2(tjnd, schooltype, districtid);
            }
            else
            {
                return service.GetReport2(tjnd, schooltype, districtid);
            }
        }
    }
    public class ReportManger3 : IReport
    {
        Report_TB_GradeService service = new Report_TB_GradeService();
        AgeReportService ageService = new AgeReportService();
        public DataSet GetReport(string tjnd, string schooltype, string districtid, string ctype)
        {
            if (ctype == "Age")
            {
                return ageService.GetReport3(tjnd, schooltype, districtid);
            }
            else
            {
                return service.GetReport3(tjnd, schooltype, districtid);
            }
        }
    }
    public class ReportManger4 : IReport
    {
        Report_TB_GradeService service = new Report_TB_GradeService();
        AgeReportService ageService = new AgeReportService();
        public DataSet GetReport(string tjnd, string schooltype, string districtid, string ctype)
        {
            if (ctype == "Age")
            {
                return ageService.GetReport4(tjnd, schooltype, districtid);
            }
            else
            {
                return service.GetReport4(tjnd, schooltype, districtid);
            }
        }
    }
    public class ReportMangerSg : IReport
    {
        Report_TB_GradeService service = new Report_TB_GradeService();
        AgeReportService ageService = new AgeReportService();
        public DataSet GetReport(string tjnd, string schooltype, string districtid, string ctype)
        {
            if (ctype == "Age")
            {
                return ageService.GetReportSg(tjnd, schooltype, districtid);
            }
            else
            {
                return service.GetReportSg(tjnd, schooltype, districtid);
            }
        }
    }
    public class ReportMangerTz : IReport
    {
        Report_TB_GradeService service = new Report_TB_GradeService();
        AgeReportService ageService = new AgeReportService();
        public DataSet GetReport(string tjnd, string schooltype, string districtid, string ctype)
        {
            if (ctype == "Age")
            {
                return ageService.GetReportTz(tjnd, schooltype, districtid);
            }
            else
            {
                return service.GetReportTz(tjnd, schooltype, districtid);
            }
        }
    }
    public class ReportMangerXw : IReport
    {
        Report_TB_GradeService service = new Report_TB_GradeService();
        AgeReportService ageService = new AgeReportService();
        public DataSet GetReport(string tjnd, string schooltype, string districtid, string ctype)
        {
            if (ctype == "Age")
            {
                return ageService.GetReportXw(tjnd, schooltype, districtid);
            }
            else
            {
                return service.GetReportXw(tjnd, schooltype, districtid);
            }
        }
    }

    public class ReportMangerFhl : IReport
    {
        Report_TB_GradeService service = new Report_TB_GradeService();
        AgeReportService ageService = new AgeReportService();
        public DataSet GetReport(string tjnd, string schooltype, string districtid, string ctype)
        {
            if (ctype == "Age")
            {
                return ageService.GetReportFhl(tjnd, schooltype, districtid);
            }
            else
            {
                return service.GetReportFhl(tjnd, schooltype, districtid);
            }
        }
    }
    public interface IReport
    {
        DataSet GetReport(string tjnd, string schooltype, string districtid,string ctype);
    }
    public enum ReportType
    {
        Sg,
        Tz,
        Xw,
        Hfl,
    }
}
